package com.three.crm.location;

import android.content.Intent;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.core.app.JobIntentService;

import com.amap.api.location.AMapLocation;

public class UploadLocationService extends JobIntentService {

    private AmapLocationUtil locationUtil = null;

    @Override
    protected void onHandleWork(@NonNull Intent intent) {
        Log.i("TAG","开始执行任务.....................");
        if (locationUtil == null) {
            locationUtil = new AmapLocationUtil(getApplicationContext());
        }
        locationUtil.initLocation();
        locationUtil.startLocation();
        locationUtil.setOnCallBackListener(new AmapLocationUtil.onCallBackListener() {
            @Override
            public void onCallBack(double longitude, double latitude, AMapLocation location, boolean isSucdess, String address) {
                if (isSucdess){
                    LocationUtils.getInstance().onUploadLocation(latitude,longitude);
                }
            }
        });
    }

}
